/*
 * Copyright (C) 2008-2009 Google Inc.
 * 
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not
 * use this file except in compliance with the License. You may obtain a copy of
 * the License at
 * 
 * http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
 * License for the specific language governing permissions and limitations under
 * the License.
 */

package org.kos.android.rusoftkeyboard;

import android.content.Context;
import android.content.res.Resources;
import android.content.res.XmlResourceParser;
import android.inputmethodservice.Keyboard;

public class CyrillicKeyboard extends Keyboard {

    public CyrillicKeyboard(final Context context, final int xmlLayoutResId) {
        super(context, xmlLayoutResId);
    }

    public CyrillicKeyboard(final Context context, final int layoutTemplateResId,
            final CharSequence characters, final int columns, final int horizontalPadding) {
        super(context, layoutTemplateResId, characters, columns, horizontalPadding);
    }

    @Override
    protected Key createKeyFromXml(final Resources res, final Row parent, final int x, final int y,
            final XmlResourceParser parser) {
        return new LatinKey(res, parent, x, y, parser);
    }

    static class LatinKey extends Key {

        public LatinKey(final Resources res, final Row parent, final int x, final int y, final XmlResourceParser parser) {
            super(res, parent, x, y, parser);
        }

        /**
         * Overriding this method so that we can reduce the target area for the key that
         * closes the keyboard.
         */
        @Override
        public boolean isInside(final int x, final int y) {
            return super.isInside(x, codes[0] == KEYCODE_CANCEL ? y - 10 : y);
        }
    }

}